package com.tjshop.android.model.tj.json;

import java.io.Serializable;

import org.json.JSONArray;
import org.json.JSONObject;

import com.tjshop.android.model.BaseObject;

public class CartModel extends BaseObject implements Serializable {
	private String gid;//"gid": "769",
    private String gname;//"gname": 
    private float price;//"price": "12.00",
    private int num;//"num": "1",
    private String thumb;//"path": "shop.511511.com/","thumb": "images/201412/thumb_img/769_thumb_G_1418858046342.jpg",
    private String attrname;//"attrname": "0",
    private String attrvalue;//"attrvalue": "0"
    
    
	public String getGid() {
		return gid;
	}

	public void setGid(String gid) {
		this.gid = gid;
	}

	public String getGname() {
		return gname;
	}

	public void setGname(String gname) {
		this.gname = gname;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public String getThumb() {
		return thumb;
	}

	public void setThumb(String thumb) {
		this.thumb = thumb;
	}

	public String getAttrname() {
		return attrname;
	}

	public void setAttrname(String attrname) {
		this.attrname = attrname;
	}

	public String getAttrvalue() {
		return attrvalue;
	}

	public void setAttrvalue(String attrvalue) {
		this.attrvalue = attrvalue;
	}

	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((attrname == null) ? 0 : attrname.hashCode());
		result = prime * result
				+ ((attrvalue == null) ? 0 : attrvalue.hashCode());
		result = prime * result + ((gid == null) ? 0 : gid.hashCode());
		result = prime * result + ((gname == null) ? 0 : gname.hashCode());
		result = prime * result + num;
		result = prime * result + Float.floatToIntBits(price);
		result = prime * result + ((thumb == null) ? 0 : thumb.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CartModel other = (CartModel) obj;
		if (attrname == null) {
			if (other.attrname != null)
				return false;
		} else if (!attrname.equals(other.attrname))
			return false;
		if (attrvalue == null) {
			if (other.attrvalue != null)
				return false;
		} else if (!attrvalue.equals(other.attrvalue))
			return false;
		if (gid == null) {
			if (other.gid != null)
				return false;
		} else if (!gid.equals(other.gid))
			return false;
		if (gname == null) {
			if (other.gname != null)
				return false;
		} else if (!gname.equals(other.gname))
			return false;
		if (num != other.num)
			return false;
		if (Float.floatToIntBits(price) != Float.floatToIntBits(other.price))
			return false;
		if (thumb == null) {
			if (other.thumb != null)
				return false;
		} else if (!thumb.equals(other.thumb))
			return false;
		return true;
	}

	@Override
	public void parse(JSONObject data) {
		setGid(getString(data, "gid"));//"gid": "769",
        setGname(getString(data, "gname"));//"gname": "仲景 明目地黄丸 200S  滋肾养肝 肝肾阴虚 目涩畏光",
        setPrice(Float.parseFloat(getString(data, "price")));//"price": "12.00",
        setNum(Integer.parseInt(getString(data, "num")));//"num": "1",
        setThumb("http://"+getString(data, "path")+getString(data, "thumb"));//"path": "shop.511511.com/",
        setAttrname(getString(data, "attrname"));//"attrname": "0",
        setAttrvalue(getString(data, "attrvalue"));//"attrvalue": "0"
	}

	@Override
	public void parse(JSONArray data) {
		
	}


}
